const fs = require('fs')
//以流的方式读取文件
var readStream=fs.createReadStream('demo.txt');
var str='';//保存数据
readStream.on('data',function(chunk){
    str+=chunk;
    console.log(chunk);
})
//读取完成
readStream.on('end',function(chunk){
    console.log(str);
})
//读取失败
readStream.on('error',function(err){
    console.log(err);
})
